try {
const locRes = await departmentsApi.getDepartments();
this.setState({ locations: locRes.data });
resolve();
} catch (err) {
reject();
return;
}
resolve();
})
render() {
if (this.props.error) {
return (<ErrorPage message={this.props.errorMessage} />);
}
const { classes } = this.props;
return (
<div className={classes.root}>
<Notifications ref={this.notificationsRef} />
<div className={classes.table}>
<MaterialTable
columns={[
{ title: 'Department', field: 'location' },
{ title: 'Color', field: 'color' },
{ title: 'Short Name', field: 'shortLocation' },
]}
data={this.state.locations}
title="Departments"
options={{
pageSize: 25,
pageSizeOptions: [25, 50, 100],
exportButton: true,
emptyRowsWhenPaging: false,
addRowPosition: 'first',
}}
editable={{
onRowAdd: this.onRowAdd,
onRowUpdate: this.onRowUpdate,
onRowDelete: this.onRowDelete,
}}
/>
</div>
</div>
);
}
}
export default Home;